package com.rm.zeyou.service.impl;

import com.rm.zeyou.entity.UserMember;
import com.rm.zeyou.mapper.UserMemberMapper;
import com.rm.zeyou.service.UserMemberService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rm.zeyou.util.check.CheckEmptyUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 用户会员表 服务实现类
 * </p>
 *
 * @author YanYang
 * @since 2025-03-12 15:55:09
 */
@Service
public class UserMemberServiceImpl extends ServiceImpl<UserMemberMapper, UserMember> implements UserMemberService {
    @Resource
    private UserMemberMapper userMemberMapper;

    @Override
    public void closeUserMember() {
        List<UserMember> userMembers = userMemberMapper.selectList(null);
        if (!CheckEmptyUtil.isEmpty(userMembers)){
            for (UserMember userMember : userMembers) {
                if (new Date().after(userMember.getExpiryTime())){
                    userMemberMapper.deleteData(userMember.getId());
                }
            }
        }
    }
}
